/**
 * Created by webhugo on 16-10-16.
 */
var sequelizex = require('sequelize-short');
var shortDataTypes = sequelizex.DataTypes;

module.exports = function (sequelize, DataTypes) {

    var Comment = sequelize.define('Comment', {
        text : shortDataTypes.Text(),
        //1.for topic 2 for comment
        type: shortDataTypes.Int(1),
        star: shortDataTypes.Int(0), //点赞量
        /**
         * 0 : 评论
         * 1 : 笔记
         */
        isNote : shortDataTypes.Int(0)
    }, {
        timestamps: true,
        associate: function (models) {
            models.User.hasMany(models.Comment);
            models.Comment.belongsTo(models.User);
            models.Course.hasMany(models.Comment);
            models.Comment.belongsTo(models.Course);
        },
        instanceMethods: {
        }
    });

    return Comment;
};
